package org.come.control;

import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.action.FromServerAction;
import org.come.until.GsonUtil;

import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;

/**
 * 婚姻消息服务器通知
 * 
 * @author 黄建彬
 * 
 */

public class MarryControl implements FromServerAction {
	@Override
	public void controlMessFromServer(String mes, String type) {
        if ("marry".equals(type)) {// 结婚
			marry(mes);
		} else if ("makelove".equals(type)) {
			makelove(mes);
		} else {// 离婚
			unMarry(mes);
		}

	}

	/**
	 * 结婚
	 */
	public void marry(String mes) {
		String MarrayName = GsonUtil.getGsonUtil().getgson().fromJson(mes, String.class);
		FrameMessageChangeJpanel.addtext(6, "恭喜您，已经和" + MarrayName + "结为夫妻！！", null, null);
		ImageMixDeal.userimg.Dialogue("恭喜您，已经和" + MarrayName + "结为夫妻！！");
		RoleData.getRoleData().getLoginResult().setMarryObject(MarrayName);
	}
	/**离婚*/
	public void unMarry(String mes) {
		String MarrayName = GsonUtil.getGsonUtil().getgson().fromJson(mes, String.class);
		FrameMessageChangeJpanel.addtext(6, "您和" + MarrayName + "已经解除婚约", null, null);
		ImageMixDeal.userimg.Dialogue("您和" + MarrayName + "已经解除婚约");
		RoleData.getRoleData().getLoginResult().setMarryObject(null);
	}
	/**洞房*/
	public void makelove(String mes) {
		ImageMixDeal.userimg.Dialogue("已经洞房！！");
		if ("女".equals(RoleData.getRoleData().getLoginResult().getSex())) {
			RoleData.getRoleData().getLoginResult().setHavebaby(100);
			RoleData.getRoleData().getLoginResult().setBabyState("备孕");
			ImageMixDeal.userimg.Dialogue("开始备孕");
		}
	}

}
